import os
import os.path
import zipfile
from cStringIO import StringIO
from django.conf import settings

def store(data, path):
    game_path = os.path.abspath(os.path.join(settings.ARCADE_STORAGE_PATH, path))
    if not os.path.exists(game_path):
        os.makedirs(game_path)
        
    zip_file = zipfile.ZipFile(data)
    for fileinfo in zip_file.infolist():
        fname = os.path.basename(fileinfo.filename)
        if fname:
            print "writing ", fname
            data = zip_file.read(fileinfo.filename)
            f = open(os.path.join(game_path, fname), 'wb')
            f.write(data)
            f.close()    
    